﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <script src="Scripts/jquery/jquery-1.11.0.min.js"></script>
    <script>
        $(function () {
            process(false);

            $('#btnLogin').click(function () {
                processStart();

                var user = $('#txtUser').val(),
                    pass = $('#txtPassword').val();

                //$.post("http://djd.iii-markets.com/Beta/Mods/account/autologin.aspx?cg=djd", {
                $.post("http://dlt/imarkets/Mods/Front/default.aspx?cg=djd", {
                    iuser: user,
                    ipass: pass
                })
                  .done(function (data) {
                      processLogin(data);
                  });
            });
            function processStart() {
                process();
            };
            function processLogin(data) {
                process(false);
                if (data) {
                    data = $.parseJSON(data);
                    console.log(data);
                    if (data.status == 1) {
                        alert(data.url);
                        //location.href = "http://localhost/imarkets/index.aspx?cg=djd"                                                
                        var url = data.url + '?cg=djd&itoken=' + data.token;
                        window.open(url, '_blank');
                        //location.href = url;
                    }
                    else {
                        $('#lblInfo').html(data.description);
                    }
                }
                else {
                    $('#lblInfo').html('Page not found');
                }

            };
            function process(flag) {
                if (flag == undefined || flag) {
                    $('.progress').show();
                }
                else {
                    $('.progress').hide();
                }
            }
        });
    </script>
</head>
<body>
    <div class="container">
        <fieldset class="form-horizontal">
            <legend></legend>
            <div class="form-group">
                <label for="txtUser">User</label>
                <input type="text" class="form-control" id="txtUser" value="djd_dlt2" />
            </div>
            <div class="form-group">
                <label for="txtPassword">Pass</label>
                <input type="password" class="form-control" id="txtPassword" value="123456" />
            </div>
            <div class="form-group">
                <button type="button" id="btnLogin">
                    Login
                </button>
            </div>
            <div class="form-group">
                <div class="progress">
                    <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
                        <span>Processing...</span>
                    </div>
                </div>
                <label class="label-danger" id="lblInfo"></label>
            </div>
            <div class="hide">
            </div>
        </fieldset>
    </div>
</body>
</html>
